import os
import sys



#wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
#wget https://static.dev.sifive.com/dev-tools/riscv-openocd-0.10.0-2019.08.2-x86_64-linux-centos6.tar.gz
#wget -c https://static.dev.sifive.com/dev-tools/riscv-openocd-0.10.0-2019.08.2-x86_64-linux-ubuntu14.tar.gz
#wget -c https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz
sifive_link = 'https://static.dev.sifive.com/dev-tools'
sifive_files = [
    #'riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz',
    #'riscv-openocd-0.10.0-2019.08.2-x86_64-linux-centos6.tar.gz',
    #'riscv-openocd-0.10.0-2019.08.2-x86_64-linux-ubuntu14.tar.gz',
    #'riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz',
    'riscv-qemu-4.1.0-2019.08.0-x86_64-apple-darwin.tar.gz',
    'riscv-openocd-0.10.0-2019.08.2-x86_64-apple-darwin.tar.gz',
    'riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-apple-darwin.tar.gz',
    #'FreedomStudio/2019.08/FreedomStudio-2019-08-2-mac64.tar.gz',
]

for f in sifive_files:
    cmd_wget = 'wget -c %s/%s .' % (sifive_link, f)
    #cmd_wget = 'wget -c %s .' % (f)
    cmd_tar = 'tar xf %s' % (f)
    print(cmd_wget)
    print(cmd_tar)
    os.system(cmd_wget)
    os.system(cmd_tar)
